<?php

include_once '../recursos.php';

class CrearOfertaPostgres extends PHPUnit_Framework_TestCase {

    protected $idEquipo = 1000;
    protected $idFutbolista = 1000;

    public function tearDown() {
        $conn = conectarDbPostgres();
        $sql = "delete FROM is_db.offer where id_team='$this->idEquipo' and id_player='$this->idFutbolista'";
        $result1 = pg_query($sql) or die();
    }

    public function testCrearOfertaPostgres() {
        $precio = 100000;
        $clausula = 1000000;
        crearOfertaPostgres($this->idEquipo, $this->idFutbolista, $precio, $clausula,0,0);
        $sql = "select count(*) FROM is_db.offer where id_team='$this->idEquipo' and id_player='$this->idFutbolista' and price=$precio and clause=$clausula";
        $result = pg_query($sql) or die();
        $linea=pg_fetch_array($result);
        $this->assertEquals(1, $linea["count"]);
    }
    
    

}

?>
